package com.cy.java.basic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;

public abstract class   Dog {
       abstract void run();

}
class xo extends  Dog {
    @Override
    void run() {
        System.out.println("run ");
    }
}
 class Puppy{
    public Puppy(String name){
        //这个构造器仅有一个参数：name
        System.out.println("小狗的名字是 : " + name );
    }
    public static void main(String[] args){
        final Test test = new Test();
        ClassLoader classLoader=new Test().getClass().getClassLoader();
        Class<?>[] inter=test.getClass().getInterfaces();

        InvocationHandler handler=new InvocationHandler() {

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
             Object result=   method.invoke(test, args);

                for (int i = 0; i <args.length ; i++) {
                    System.out.println(args[i]);

                }
                System.out.println(Arrays.toString(args));
                return result;
            }
        };
       Object proxyInstance=  Proxy.newProxyInstance(classLoader,inter,handler);

        System.out.println(proxyInstance.getClass().getName());

        Dog dog = new Dog() {
            @Override
            void run() {
                System.out.println("ren");
            }
        };
        dog.run();


        int x = 0140;
        System.out.println(x);
        int b = 0x140;
        System.out.println(b);
        // 下面的语句将创建一个Puppy对象
        Puppy myPuppy = new Puppy( "tommy" );
    }
}
 class Test{
    public void pupAge(){
        int age;
       // age = age + 7;
      //  System.out.println("小狗的年龄是 : " + age);
    }

    public static void main(String[] args){

        int []x ={1,2,3};
        for (Object i: x
             ) {
            System.out.println(i);
        }
        for (int i = 0; i <10 ; i++) {
           
            System.out.println(i);
        }
        int b = 1;
        int a = (b==1)?20:30;
        System.out.println(a);
        Test test = new Test();
        test.pupAge();
    }
}